package br.com.ps.bombertournament.game.scene;

import java.util.List;
import java.util.Map;
import java.util.Random;

import br.com.ps.bombertournament.App;
import br.com.ps.bombertournament.SceneManager;
import br.com.ps.bombertournament.game.Layer;
import br.com.ps.bombertournament.game.Renderer;
import br.com.ps.bombertournament.game.VolumeCollisionEngine;
import br.com.ps.bombertournament.game.WrapperMap;
import br.com.ps.bombertournament.game.object.Empty;
import br.com.ps.bombertournament.game.object.FactoryGameObject;
import br.com.ps.bombertournament.game.object.Floor;
import br.com.ps.bombertournament.game.object.Item;
import br.com.ps.bombertournament.game.object.Player;
import br.com.ps.bombertournament.game.object.Player.Keyboard;
import br.com.ps.bombertournament.game.object.SuperWall;
import br.com.ps.bombertournament.game.object.Wall;

import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.OrthographicCamera;

import flexjson.JSONDeserializer;

public class BattleScene extends BaseScene implements InputProcessor {

	private static final int CONTROLLER_LAYER_LEVEL = 9;
	private String configurationsPath;
	private WrapperMap configurations;

	private Player player;
	
	private static final Random random = new Random();
	
	private Layer virtualController;
	private Empty controller;
	private Empty buttonBomb;
	private int controllerMousePointer = -1;
	private int buttonBombMousePointer = -1;
	private int controllerXPointZero = 0;
	private int controllerYPointZero = 0;
	
	private int battleDimmensionX = 12;
	private int battleDimmensionY = 12;
	
	private int positionBattleX = 115;
	private int positionBattleY = 0;
	
	private static final String FILE_PROPERTY = "file";
	private static final String MUSIC_PROPERTY = "music";
	private static final String VOLUME_PROPERTY = "volume";
	private static final String LOOP_PROPERTY = "loop";
	
	private static final String HEIGHT_PROPERTY = "height";
	private static final String WIDTH_PROPERTY = "width";
	private static final String Y_PROPERTY = "y";
	private static final String X_PROPERTY = "x";
	private static final String CAMERA_PROPERTY = "camera";
	
	private static final String CONFIGURATIONS_PROPRETY = "configurations";
	
	public BattleScene(String configurationsPath) {
		this.configurationsPath = configurationsPath;
	}

	@Override
	public void create(SceneManager sceneManager) {
		super.create(sceneManager);
		
		this.configurations = getWrapperMap(configurationsPath);

		{ // Loading the camera's configurations
			if (configurations.containsKey(CAMERA_PROPERTY)) {
				WrapperMap cameraConfigurations = configurations.getMap(CAMERA_PROPERTY);
				
				if (cameraConfigurations.containsKey(X_PROPERTY) 
						&& cameraConfigurations.containsKey(Y_PROPERTY)
						&& cameraConfigurations.containsKey(WIDTH_PROPERTY)
						&& cameraConfigurations.containsKey(HEIGHT_PROPERTY)) {
					OrthographicCamera camera = new OrthographicCamera();
					
					camera.position.x = cameraConfigurations.getInteger(X_PROPERTY);
					camera.position.y = cameraConfigurations.getInteger(Y_PROPERTY);
					camera.viewportWidth = cameraConfigurations.getInteger(WIDTH_PROPERTY);
					camera.viewportHeight = cameraConfigurations.getInteger(HEIGHT_PROPERTY);
					
					super.setCamera(camera);
				}
			}
		}
		
		{ // Loading the music's scene
			if (configurations.containsKey(MUSIC_PROPERTY)) {
				WrapperMap musicConfigurations = configurations.getMap(MUSIC_PROPERTY);
				
				if (musicConfigurations.containsKey(FILE_PROPERTY)) {
					Music music = Gdx.audio.newMusic(Gdx.files.internal(musicConfigurations.getString(FILE_PROPERTY)));
					
					music.setLooping(musicConfigurations.getBoolean(LOOP_PROPERTY, false));
					
					if (musicConfigurations.containsKey(VOLUME_PROPERTY)) {
						music.setVolume(musicConfigurations.getFloat(VOLUME_PROPERTY));
					}
					
					super.setMusic(music);
				}
			}
		}
		
		// Calculate the scale
		Renderer.scaleX = 2;
		Renderer.scaleY = 2;
		// Calculation of position battle scene 
//		positionBattleX = (int) ((Gdx.graphics.getWidth() / 2) - (16 * ((battleDimmensionX + 2) / 2) * Game.scaleX));
		
		
		{ // Adding the floor
			int priority = 0;
			Layer floorLayer = new Layer(super.getRenderer(), 25);
			
			WrapperMap floorSceneConfigurations = getNode(configurations,  "library@id/FLOOR");
			WrapperMap floorConfigurations = getWrapperMap(floorSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
			
			if (floorSceneConfigurations != null) {
				
				int floorWidth = floorConfigurations.getInteger("width");
				int floorHeight = floorConfigurations.getInteger("height");
				for (int i = 1; i < battleDimmensionX; i++) {
					for (int j = 1; j < battleDimmensionY; j++) {
						Floor floor = FactoryGameObject.createFloor(floorSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
						
						floor.setPosition(
								(positionBattleX + (floorWidth * i)) * Renderer.scaleX,
								(positionBattleY + (floorHeight * j)) * Renderer.scaleY);
						
						floor.setScale(Renderer.scaleX, Renderer.scaleY);
						
						floorLayer.add(floor);
					}
				}
				
				floorLayer.addPending();
				
				super.getRenderer().addLayer(priority, floorLayer);
			}
		}

		int priority = 1;
		Layer battleLayer = new Layer(super.getRenderer(), 250);
		{ // Adding the Walls
			{ // SuperWall DownLeft
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_DOWN_LEFT");
				if (superWallSceneConfigurations != null) {
					SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
					
					superWall.setPosition(
							positionBattleX * Renderer.scaleX,
							positionBattleY * Renderer.scaleY);
					
					superWall.setScale(Renderer.scaleX, Renderer.scaleY);
					
					battleLayer.add(superWall);
				}
			}
			
			{ // SuperWall Down
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_DOWN");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));;
				if (superWallSceneConfigurations != null) {
					
					int superWallWidth = superWallConfigurations.getInteger("width");
					for (int i = 1; i < battleDimmensionX; i++) {
						SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
						
						superWall.setPosition(
								(positionBattleX + (superWallWidth * i)) * Renderer.scaleX,
								positionBattleY * Renderer.scaleY);
						
						superWall.setScale(Renderer.scaleX, Renderer.scaleY);
						
						battleLayer.add(superWall);
					}
				}
			}
			
			{ // SuperWall DownRight
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_DOWN_RIGHT");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				if (superWallSceneConfigurations != null) {
					
					int superWallWidth = superWallConfigurations.getInteger("width");
					SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
					
					superWall.setPosition(
							(positionBattleX + (superWallWidth * battleDimmensionX)) * Renderer.scaleX, 
							positionBattleY * Renderer.scaleY);
					
					superWall.setScale(Renderer.scaleX, Renderer.scaleY);
					
					battleLayer.add(superWall);
				}
			}
			
			{ // SuperWall Right
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_RIGHT");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				if (superWallSceneConfigurations != null) {
					
					int superWallWidth = superWallConfigurations.getInteger("width");
					int superWallHeight = superWallConfigurations.getInteger("height");
					for (int i = 1; i < battleDimmensionY; i++) {
						SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
						
						superWall.setPosition(
								(positionBattleX + (superWallWidth * battleDimmensionX)) * Renderer.scaleX, 
								(positionBattleY + superWallHeight * i) * Renderer.scaleY);
						
						superWall.setScale(Renderer.scaleX, Renderer.scaleY);
						
						battleLayer.add(superWall);
					}
				}
			}
			
			{ // SuperWall Left
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_LEFT");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				if (superWallSceneConfigurations != null) {
					int superWallHeight = superWallConfigurations.getInteger("height");
					for (int i = 1; i < battleDimmensionY; i++) {
						SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
						
						superWall.setPosition(
								positionBattleX  * Renderer.scaleX, 
								(positionBattleY + superWallHeight * i) * Renderer.scaleY);
						
						superWall.setScale(Renderer.scaleX, Renderer.scaleY);
						
						battleLayer.add(superWall);
					}
				}
			}
			
			{ // SuperWall Up
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_UP");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));;
				if (superWallSceneConfigurations != null) {
					
					int superWallWidth = superWallConfigurations.getInteger("width");
					int superWallHeight = superWallConfigurations.getInteger("height");
					for (int i = 1; i < battleDimmensionX; i++) {
						SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
						
						superWall.setPosition(
								(positionBattleX + (superWallWidth * i)) * Renderer.scaleX,
								(positionBattleY + superWallHeight * battleDimmensionY) * Renderer.scaleY);
						
						superWall.setScale(Renderer.scaleX, Renderer.scaleY);
						
						battleLayer.add(superWall);
					}
				}
			}
			
			{ // SuperWall UpLeft
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_UP_LEFT");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				if (superWallSceneConfigurations != null) {
					
					int superWallHeight = superWallConfigurations.getInteger("height");
					SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
					
					superWall.setPosition(
							positionBattleX * Renderer.scaleX, 
							(positionBattleY + superWallHeight * battleDimmensionY) * Renderer.scaleY);
					
					superWall.setScale(Renderer.scaleX, Renderer.scaleY);
					
					battleLayer.add(superWall);
				}
			}
			
			{ // SuperWall UpRight
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL_UP_RIGHT");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				if (superWallSceneConfigurations != null) {
					
					int superWallWidth = superWallConfigurations.getInteger("width");
					int superWallHeight = superWallConfigurations.getInteger("height");
					SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
					
					superWall.setPosition(
							(positionBattleX + (superWallWidth * battleDimmensionX)) * Renderer.scaleX, 
							(positionBattleY + superWallHeight * battleDimmensionY) * Renderer.scaleY);
					
					superWall.setScale(Renderer.scaleX, Renderer.scaleY);
					
					battleLayer.add(superWall);
				}
			}
			
			{ // SuperWalls inside of battle scene
				WrapperMap superWallSceneConfigurations = getNode(configurations,  "library@id/SUPER_WALL");
				WrapperMap superWallConfigurations = getWrapperMap(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				
				if (superWallSceneConfigurations != null) {
					
					int floorWidth = superWallConfigurations.getInteger("width");
					int floorHeight = superWallConfigurations.getInteger("height");
					for (int i = 2; i < battleDimmensionX; i+=2) {
						for (int j = 2; j < battleDimmensionY; j+=2) {
							SuperWall superWall = FactoryGameObject.createSuperWall(superWallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
							
							superWall.setPosition(
									(positionBattleX + (floorWidth * i)) * Renderer.scaleX,
									(positionBattleY + (floorHeight * j)) * Renderer.scaleY);
							
							superWall.setScale(Renderer.scaleX, Renderer.scaleY);
							
							battleLayer.add(superWall);
						}
					}
					
				}
			}
			
			{ // Adding the Walls
				WrapperMap wallSceneConfigurations = getNode(configurations,  "library@id/WALL");
				WrapperMap wallConfigurations = getWrapperMap(wallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
				
				if (wallSceneConfigurations != null) {
					
					int floorWidth = wallConfigurations.getInteger("width");
					int floorHeight = wallConfigurations.getInteger("height");
					for (int i = 1; i < battleDimmensionX; i++) {
						for (int j = 1; j < battleDimmensionY; j++) {
							
							{ // Removing the walls
								// Removing the wall with the same position of the SuperWalls 
								if (i % 2 == 0 && j % 2 == 0) {
									continue;
								}
								
								// Removing the wall for player 1
								if ((i == 1 && j == battleDimmensionY - 1) 
										|| (i == 1 && j == battleDimmensionY - 2) 
										|| (i == 2 && j == battleDimmensionY - 1)) {
									continue;
								}
								
								// Removing the wall for player 2
								if ((i == battleDimmensionX - 1 && j == battleDimmensionY - 2) 
										|| (i == battleDimmensionX - 2 && j == battleDimmensionY - 1)
										|| (i == battleDimmensionX - 1 && j == battleDimmensionY - 1)) {
									continue;
								}
								
								// Removing the wall for player 3
								if ((i == 1 && j == 1) 
										|| (i == 1 && j == 2)
										|| (i == 2&& j == 1)) {
									continue;
								}
								
								// Removing the wall for player 4
								if ((i == battleDimmensionX - 1 && j == 1) 
										|| (i == battleDimmensionX - 2 && j == 1) 
										|| (i == battleDimmensionX - 1 && j == 2)) {
									continue;
								}
								
								// Removing the wall for player 5
								if (										
										(i == battleDimmensionX / 2 - 1 && j == battleDimmensionY / 2 - 1 && random.nextInt() % 2 == 0)
										|| (i == battleDimmensionX / 2 && j == battleDimmensionY / 2 - 1)
										|| (i == battleDimmensionX / 2 + 1 && j == battleDimmensionY / 2 - 1)
										
										|| (i == battleDimmensionX / 2 - 1 && j == battleDimmensionY / 2 && random.nextInt() % 2 == 0)
										|| (i == battleDimmensionX / 2 && j == battleDimmensionY / 2)
										|| (i == battleDimmensionX / 2 + 1 && j == battleDimmensionY / 2 && random.nextInt() % 2 == 0)
										
										|| (i == battleDimmensionX / 2 - 1 && j == battleDimmensionY / 2 + 1)
										|| (i == battleDimmensionX / 2 && j == battleDimmensionY / 2 + 1)
										|| (i == battleDimmensionX / 2 + 1 && j == battleDimmensionY / 2 + 1 && random.nextInt() % 2 == 0)) {
									continue;
								}
							}
							
							Wall wall = FactoryGameObject.createWall(wallSceneConfigurations.getString(CONFIGURATIONS_PROPRETY));
							
							wall.setPosition(
									(positionBattleX + (floorWidth * i)) * Renderer.scaleX,
									(positionBattleY + (floorHeight * j)) * Renderer.scaleY);
							
							wall.setScale(Renderer.scaleX, Renderer.scaleY);
							
							wall.setItem(createNextItem());
							
							battleLayer.add(wall);
						}
					}
				}
			}
			
			{ // Adding the player
				player = FactoryGameObject.createPlayerBomberman();
				
				player.setPosition(
						(positionBattleX + (16 * 1)) * Renderer.scaleX,
						(positionBattleY + (16 * (battleDimmensionY - 1))) * Renderer.scaleY);
				
				player.setScale(Renderer.scaleX, Renderer.scaleY);
				
				battleLayer.add(player);
			}
			
			battleLayer.addPending();
			
			super.getRenderer().addLayer(priority, battleLayer);
		}
		
		{ // Adding the virtual controller
			Gdx.input.setInputProcessor(this);
			
			addVirtualControlLayer();
		}
		
		// Adding the system collision
		super.getRenderer().setCollisionEngine(new VolumeCollisionEngine());

		// TODO Verify if the music is enable in the user's configuration
		if (super.getMusic() != null) {
//			super.getMusic().play();
		}
	}

	private Item createNextItem() {
		Item result = null;
		
		
		
		return result;
	}

	private WrapperMap getWrapperMap(String configurationsPath) {
		String json = Gdx.files.internal(configurationsPath).readString();
		
		return new WrapperMap(new JSONDeserializer<Map<String, Object>>().deserialize(json));
	}

	private WrapperMap getNode(WrapperMap configurations, String path) {
		WrapperMap result = null;
		
		String attrKeyName = null;
		String attrKeyValue = null;
		if (path.indexOf("@") != -1) {
			attrKeyName = path.substring(path.indexOf("@") + 1, path.indexOf("/"));
			attrKeyValue = path.substring(path.indexOf("/") + 1);
			path = path.substring(0, path.indexOf("@"));
		}
		
		if (configurations.containsKey(path)) {
			Object node = configurations.getObject(path);
			if (node instanceof List) {
				List<Map<String, Object>> values = (List<Map<String, Object>>) node;
				for (Map<String, Object> item : values) {
					if (item.containsKey(attrKeyName) && item.get(attrKeyName).equals(attrKeyValue)) {
						result = new WrapperMap(item);
					}
				}
			} else if (node instanceof Map) {
				Map<String, Object> item = (Map<String, Object>) node;
				if (item.containsKey(attrKeyName) && item.get(attrKeyName).equals(attrKeyValue)) {
					result = new WrapperMap(item);
				}
			}
		}
		
		return result;
	}

	@Override
	public boolean keyDown(int keycode) {
		boolean result = false;
		
		if (keycode == Input.Keys.DOWN) {
			result = player.processEvent(Keyboard.DOWN);
		}
		if (keycode == Input.Keys.UP) {
			result = player.processEvent(Keyboard.UP);
		}
		if (keycode == Input.Keys.RIGHT) {
			result = player.processEvent(Keyboard.RIGHT);
		}
		if (keycode == Input.Keys.LEFT) {
			result = player.processEvent(Keyboard.LEFT);
		}
		
		if (keycode == Input.Keys.SPACE || keycode == Input.Keys.DPAD_CENTER) {
			result = player.processEvent(Keyboard.SPACE);
		}
		
		if (keycode == Input.Keys.BACKSPACE) {
			super.getSceneManager().setScene(new LoadingScene(new BattleScene("data/scene/bomber_zone/bomber_zone.json")));
		}
		
		if (result == false) {
			if (App.LOG_LEVEL == Application.LOG_INFO)
			Gdx.app.log(App.name, String.format("Keycode: %s", keycode));
		}
		
		return result;
	}

	@Override
	public boolean keyUp(int keycode) {
		// Do nothing
		return false;
	}

	@Override
	public boolean keyTyped(char character) {
		// Do nothing
		return false;
	}

	@Override
	public boolean touchDown(int x, int y, int pointer, int button) {
		boolean handled = false;
		
		if (controller.instercept(x, Gdx.graphics.getHeight() - y)) {
			controllerMousePointer = pointer;
			readTouchController(x, y);
		}
		
		if (buttonBomb.instercept(x, Gdx.graphics.getHeight() - y)) {
			buttonBombMousePointer = pointer;
			player.processEvent(Keyboard.SPACE);
		}
		
		return handled;
	}

	@Override
	public boolean touchUp(int x, int y, int pointer, int button) {
		boolean handled = false;
		
		if (controllerMousePointer == pointer) {
			controllerMousePointer = -1;
		}
		
		if (buttonBombMousePointer == pointer) {
			buttonBombMousePointer = -1;
		}
		
		return handled;
	}

	@Override
	public boolean touchDragged(int x, int y, int pointer) {
		boolean handled = false;
		
		if (controllerMousePointer == pointer) {
			readTouchController(x, y);
			handled = true;
		}
		
		return handled;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// Do nothing
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		// Do nothing
		return false;
	}
	
	/**
	 * Add the virtual control layer
	 */
	private void addVirtualControlLayer() {
		virtualController = new Layer(super.getRenderer());
		
		{ // Adding controller
			controller = FactoryGameObject.createController();
			controller.setPosition(Gdx.graphics.getWidth() * 0.03F, Gdx.graphics.getHeight() * 0.04F);
			
			virtualController.add(controller);
		}
		
		{ // Adding button bomb
			buttonBomb = FactoryGameObject.createButtonBomb();
			buttonBomb.setPosition(Gdx.graphics.getWidth() - buttonBomb.getRegionWidth() - (Gdx.graphics.getWidth() * 0.03F), (Gdx.graphics.getHeight() * 0.04F));
			
			virtualController.add(buttonBomb);
		}
		
		{ // Calculation of point zeros
			controllerXPointZero = Math.round((controller.getRegionWidth() / 2) + controller.getX());
			controllerYPointZero = Math.round((Gdx.graphics.getHeight() - controller.getY()) - (controller.getRegionHeight() / 2));
		}
		
		super.getRenderer().addLayer(CONTROLLER_LAYER_LEVEL,  virtualController);
	}
	
	/**
	 * Interprets the touch on the screen and tell to player the direction to walk
	 * 
	 * @param x Pointer X of the touch event
	 * @param y Pointer Y of the touch event
	 */
	private void readTouchController(int x, int y) {
		int draggedX = x - controllerXPointZero;
		int draggedY = y - controllerYPointZero;

		Keyboard primaryKeyCode  = null;
		double degrees = Math.round(Math.atan2(draggedY, draggedX) * 180/Math.PI);
		
		if (degrees <= 45 && degrees >= -45) {
			primaryKeyCode = Keyboard.RIGHT;
		} else if (degrees <= 135 && degrees >= 45) {
			primaryKeyCode = Keyboard.DOWN;
		} else if (degrees >= -135 && degrees <= -45) {
			primaryKeyCode = Keyboard.UP;
		} else if (degrees <= 135 || degrees >= -135) {
			primaryKeyCode = Keyboard.LEFT;
		}

//		Keyboard primaryKeyCode  = null;
//		Keyboard secondaryKeyCode = null;
//		if(degrees >= -22 && degrees <= 22) {
//			primaryKeyCode = Keyboard.RIGHT;
//		// Thumb stick position - Down
//		} else if (degrees >= 68 && degrees <= 112) {
//			primaryKeyCode = Keyboard.DOWN;
//		// Thumb stick position - Left
//		} else if((degrees >= 158 && degrees <= 180) || (degrees >= -179 && degrees <= -158)) {
//			primaryKeyCode = Keyboard.LEFT;
//		// Thumb stick position - Up			
//		} else if(degrees >= -112 && degrees <= -68) {
//			primaryKeyCode = Keyboard.UP;
//		// Thumb stick position - Up/Left
//		} else if(degrees >= -157 && degrees <= -113) {
//			primaryKeyCode = Keyboard.UP;
//			secondaryKeyCode = Keyboard.LEFT;
//		// Thumb stick position - Down/Left
//		} else if(degrees <= 157 && degrees >= 113) {
//			primaryKeyCode = Keyboard.DOWN;
//			secondaryKeyCode = Keyboard.LEFT;
//		// Thumb stick position - Up/Right
//		} else if(degrees >=-67 && degrees <= -21) {
//			primaryKeyCode = Keyboard.UP;
//			secondaryKeyCode = Keyboard.RIGHT;
//		// Thumb stick position - Down/Right
//		} else if(degrees >= 23 && degrees <= 67) {
//			primaryKeyCode = Keyboard.DOWN;
//			secondaryKeyCode = Keyboard.RIGHT;
//		}
		player.processEvent(primaryKeyCode);
	}

	public int getBattleDimmensionX() {
		return battleDimmensionX;
	}

	public int getBattleDimmensionY() {
		return battleDimmensionY;
	}

	public int getPositionBattleX() {
		return positionBattleX;
	}

	public int getPositionBattleY() {
		return positionBattleY;
	}
}
